package com.lex.controller;

import com.lex.common.annoatation.SysLog;
import com.lex.common.api.CommonResult;
import com.lex.common.enums.BusinessType;
import com.lex.entity.params.LoginLogQueryParams;
import com.lex.entity.params.SysLogQueryParams;
import com.lex.service.LogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Schema(name = "LogController", description = "日志接口")
@RequestMapping("/log")
public class LogController {
    @Autowired
    private LogService logService;

    /**
     * 获取操作日志列表
     */
    @Operation(summary = "获取操作日志列表")
    @RequestMapping(value = "/sysLogList")
    public CommonResult sysLogList(SysLogQueryParams query, Integer page, Integer pageSize) {
        return logService.getOperationLogList(query, page, pageSize);
    }
    /**
     * 获取登录日志列表
     */
    @Operation(summary = "获取登录日志列表")
    @RequestMapping(value = "/loginLogList")
    public CommonResult loginLogList(LoginLogQueryParams query, Integer page, Integer pageSize) {
        return logService.getLoginLogList(query, page, pageSize);
    }
    /**
     * 删除操作日志
     */
    @Operation(summary = "删除操作日志")
    @SysLog(title = "删除操作日志",businessType = BusinessType.DELETE)
    @RequestMapping(value = "/deleteSysLog")
    public CommonResult deleteSysLog() {
        return logService.deleteOperationLog();
    }
    /**
     * 删除登录日志
     */
    @Operation(summary = "删除登录日志")
    @SysLog(title = "删除登录日志",businessType = BusinessType.DELETE)
    @RequestMapping(value = "/deleteLoginLog")
    public CommonResult deleteLoginLog() {
        return logService.deleteLoginLog();
    }
}
